import xlrd
import pyecharts.options as opts
data=xlrd.open_workbook(r'C:\Users\chumenliuxiang\Desktop\实验室作业\第一问\第一问.xls','r')
sheet_num=data.nsheets
# print(sheet_num)
biao1=data.sheet_by_name('Sheet1')
scores=biao1.col_values(1)
scores=scores[1:]

a=b=c=d=e=0
for i in scores:
    if i<60:
        e=e+1
    elif i<70:
        d+=1
    elif i<80:
        c+=1
    elif i<90:
        b+=1
    elif i<=100:
        a+=1
student3=[]
student3.append(e)
student3.append(d)
student3.append(c)
student3.append(b)
student3.append(a)
# print(student3)
shuju=['E(0~60)','D(61~70)','C(71~80)','B(81~90)','A(91~100)']
# print(shuju)
#————————————数据处理完毕
from pyecharts import options as opts
from pyecharts.charts import Pie

(
    Pie()
    .add("", [list(z) for z in zip(shuju, student3)])
    .set_global_opts(title_opts=opts.TitleOpts(title="学习成绩的饼图",pos_left='center',pos_bottom='1%'))
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    .render("第五问.html")
)
